package com.lxinet.jeesns.modules.wechat.service.impl;

import com.lxinet.jeesns.core.dto.ResponseModel;
import com.lxinet.jeesns.core.utils.ActionUtil;
import com.lxinet.jeesns.modules.cms.entity.ArticleComment;
import com.lxinet.jeesns.modules.wechat.dao.IWechatReplyConfigDao;
import com.lxinet.jeesns.modules.wechat.entity.WechatReplyConfig;
import com.lxinet.jeesns.modules.wechat.service.IWechatReplyConfigService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by lzs on 2017/4/11.
 */
@Service("wechatReplyConfigService")
public class WechatReplyConfigServiceImpl implements IWechatReplyConfigService {

    @Resource
    private IWechatReplyConfigDao wechatReplyConfigDao;

    @Override
    public WechatReplyConfig findByWXuin(String wxuin) {
        return wechatReplyConfigDao.findByWXuin(wxuin);
    }

    @Override
    public void changeFlag(Integer id,Integer flag) {
         wechatReplyConfigDao.changeFlag(id,flag);
    }

    @Override
    public int save(WechatReplyConfig wechatReplyConfig){
        return wechatReplyConfigDao.save(wechatReplyConfig);
    }

    @Override
    public List<WechatReplyConfig> getAll() {
        return wechatReplyConfigDao.getAll();
    }

    @Override
    public WechatReplyConfig findById(Integer id) {
        return wechatReplyConfigDao.findById(id);
    }

    public int update(WechatReplyConfig wechatReplyConfig){
        return wechatReplyConfigDao.update(wechatReplyConfig);
    }

    @Override
    public ResponseModel delete(Integer id) {
        WechatReplyConfig wechatReplyConfig = this.findById(id);
        if(wechatReplyConfig == null){
            return new ResponseModel(-1,"配置不存在");
        }
        int result = wechatReplyConfigDao.delete(id);
        if(result == 1){
            return new ResponseModel(1,"删除成功");
        }
        return new ResponseModel(-1,"删除失败");
    }


}
